home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / v0_98 / natsci.bst < prev    next >
Text File  |  1990-10-02  |  18KB  |  957 lines

  1. %NAME: natsci.bst
  2. %% BibTeX `natsci' family
  3. %
  4. % **********************************************************
  5. % ***** This will not work with BibTeX 0.99a or later ******
  6. % **********************************************************
  7. %
  8. %% 08 jan 87 gildea natural sciences version created from this version:
  9.     % version 0.98c for BibTeX versions 0.98i or later, LaTeX version 2.08
  10.     % Copyright (C) 1985, all rights reserved
  11.     % Copying of this file is authorized only if either
  12.     % (1) you make absolutely no changes to your copy, including name, or
  13.     % (2) if you do make changes, you name it something other than
  14.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst
  15.     % This restriction helps ensure that all standard styles are identical
  16.  
  17. %% Copyright (c) 1987 by Stephen Gildea
  18. %% Permission to copy all or part of this work is granted, provided
  19. %% that the copies are not made or distributed for resale, and that
  20. %% the copyright notice and this notice are retained.
  21. %% 
  22. %% THIS WORK IS PROVIDED ON AN "AS IS" BASIS.  THE AUTHOR PROVIDES NO
  23. %% WARRANTY WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THE WORK,
  24. %% INCLUDING WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR FITNESS
  25. %% FOR ANY PARTICULAR PURPOSE.
  26.  
  27. %% Natural Sciences bibliography format:
  28. %%  citations in the text look like (Gildea, 1987).
  29. %%  There are no labels in the bibliography.
  30. %%  There are no "sentences"; commas separate all parts of an entry.
  31. %%  The first author's name is reversed: Last, First.
  32. %%  The number is not listed, just the volume.
  33. %%  For two entries by the same author in the same year, a letter ("a",
  34. %%    "b", etc.) is added to the year in the reference list as well as in
  35. %%    the citation label.
  36. %%
  37. %% Other things fixed by Gildea:
  38. %%  The editors are listed after, not before, the booktitle.
  39. %%  The comma after a field is italicized if the field was.
  40.  
  41. %% Note to users:
  42. %%  Since the natsci format does not use labels in the bibliography,
  43. %%  the LaTeX style needs to be modified slightly.  As a minimum,
  44. %%  redefine \@biblabel as follows:
  45. %%
  46. %%  \def\@biblabel#1{\hfill}
  47. %%
  48. %%  To get the indenting right, the following should be added to the
  49. %%  list initialization in the definition of the thebibliography
  50. %%  environment:
  51. %%
  52. %%  \itemindent=-\leftmargin
  53. %%
  54. %%  Of course, the best solution is to use a LaTeX style that was designed
  55. %%  to use this bibliography style.
  56.  
  57. %% The commented source is available from the author.
  58. %% If you make any improvements, I'd like to hear about them.
  59. %% Stephen Gildea
  60. %% MIT Earth Resources Lab
  61. %% Cambridge, Mass. 02139
  62. %% mit-erl!gildea
  63. %% gildea@erl.mit.edu
  64.  
  65. ENTRY
  66.   { address
  67.     author
  68.     booktitle
  69.     chapter
  70.     edition
  71.     editor
  72.     howpublished
  73.     institution
  74.     journal
  75.     key
  76.     month
  77.     note
  78.     number
  79.     organization
  80.     pages
  81.     publisher
  82.     school
  83.     series
  84.     title
  85.     type
  86.     volume
  87.     year
  88.   }
  89.   {}
  90.  
  91.   { label extra.label sort.label }
  92.  
  93. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  94.  
  95. FUNCTION {init.state.consts}
  96. { 'before.all #0 :=
  97.   'mid.sentence #1 :=
  98.   'after.sentence #2 :=
  99.   'after.block #3 :=
  100. }
  101.  
  102. STRINGS { s t }
  103.  
  104. FUNCTION {add.comma}
  105. { duplicate$
  106.   #-1 #1 substring$ "}" =
  107.     { #-2 #1024 substring$ ",} " * }
  108.     { ", " * }
  109.   if$
  110. }
  111.  
  112. FUNCTION {output.nonnull}
  113. { 's swap$ :=
  114.   output.state mid.sentence =
  115.     { add.comma write$ }
  116.     { output.state after.block =
  117.     { add.period$ write$
  118.       newline$
  119.       "\newblock " write$
  120.     }
  121.     { output.state before.all =
  122.         'write$
  123.         { add.period$ " " * write$ }
  124.       if$
  125.     }
  126.       if$
  127.     }
  128.   if$
  129.   'output.state mid.sentence :=
  130.   s
  131. }
  132.  
  133. FUNCTION {output}
  134. { 's swap$ :=
  135.   s "" =
  136.     'skip$
  137.     { s output.nonnull }
  138.   if$
  139. }
  140.  
  141. FUNCTION {output.check}
  142. { 's swap$ :=
  143.   't swap$ :=
  144.   s "" =
  145.     { "Warning: the " t * " shouldn't be empty in " * cite$ * top$ }
  146.     { s output.nonnull }
  147.   if$
  148. }
  149.  
  150. FUNCTION {output.bibitem}
  151. { newline$
  152.  
  153.   "\bibitem[" write$
  154.   label write$
  155.   "]{" write$
  156.  
  157.   cite$ write$
  158.   "}" write$
  159.   newline$
  160.   ""
  161.   'output.state before.all :=
  162. }
  163.  
  164. FUNCTION {fin.entry}
  165. { add.period$
  166.   write$
  167.   newline$
  168. }
  169.  
  170. FUNCTION {new.block}
  171. { output.state before.all =
  172.     'skip$
  173.     { 'output.state after.block := }
  174.   if$
  175. }
  176.  
  177. FUNCTION {new.sentence}
  178. { output.state after.block =
  179.     'skip$
  180.     { output.state before.all =
  181.     'skip$
  182.     { 'output.state after.sentence := }
  183.       if$
  184.     }
  185.   if$
  186. }
  187.  
  188. FUNCTION {not}
  189. {   { #0 }
  190.     { #1 }
  191.   if$
  192. }
  193.  
  194. FUNCTION {and}
  195. {   'skip$
  196.     { pop$ #0 }
  197.   if$
  198. }
  199.  
  200. FUNCTION {or}
  201. {   { pop$ #1 }
  202.     'skip$
  203.   if$
  204. }
  205.  
  206. FUNCTION {field.or.null}
  207. { duplicate$
  208.   missing$
  209.     { pop$ "" }
  210.     'skip$
  211.   if$
  212. }
  213.  
  214. FUNCTION {italicize}
  215. { 's swap$ :=
  216.   s "" =
  217.     { "" }
  218.     { "{\it " s * "}" * }
  219.   if$
  220. }
  221.  
  222. INTEGERS { nameptr namesleft numnames }
  223.  
  224. STRINGS {nameresult}
  225.  
  226. FUNCTION {format.names}
  227. { 's swap$ :=
  228.   'nameptr #1 :=
  229.   'nameresult "" :=
  230.   'numnames s num.names$ :=
  231.   'namesleft numnames :=
  232.     { namesleft #0 > }
  233.     {
  234.  
  235.       't s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ :=
  236.  
  237.       nameptr #1 >
  238.     { namesleft #1 >
  239.         { 'nameresult nameresult ", " * t * := }
  240.         { numnames #2 >
  241.         { 'nameresult nameresult "," * := }
  242.         'skip$
  243.           if$
  244.           t "others" =
  245.         { 'nameresult nameresult " et al." * := }
  246.         { 'nameresult nameresult " and " * t * := }
  247.           if$
  248.         }
  249.       if$
  250.     }
  251.     { 'nameresult nameresult t * := }
  252.       if$
  253.       'nameptr nameptr #1 + :=
  254.       'namesleft namesleft #1 - :=
  255.     }
  256.   while$
  257.   nameresult
  258. }
  259.  
  260. FUNCTION {format.names.reverse1}
  261. { 's swap$ :=
  262.   'nameptr #1 :=
  263.   'nameresult "" :=
  264.   'numnames s num.names$ :=
  265.   'namesleft numnames :=
  266.     { namesleft #0 > }
  267.     {
  268.       nameptr #1 >
  269.     { 
  270.  
  271.           't s nameptr "{f.~}{vv~}{ll}{, jj}" format.name$ :=
  272.  
  273.           namesleft #1 >
  274.         { 'nameresult nameresult ", " * t * := }
  275.         { numnames #2 >
  276.         { 'nameresult nameresult "," * := }
  277.         'skip$
  278.           if$
  279.           t "others" =
  280.         { 'nameresult nameresult " et al." * := }
  281.         { 'nameresult nameresult " and " * t * := }
  282.           if$
  283.         }
  284.       if$
  285.     }
  286.     {
  287.  
  288.           't s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ :=
  289.  
  290.           'nameresult nameresult t * :=
  291.         }
  292.       if$
  293.       'nameptr nameptr #1 + :=
  294.       'namesleft namesleft #1 - :=
  295.     }
  296.   while$
  297.   nameresult
  298. }
  299.  
  300. FUNCTION {format.authors}
  301. { author missing$
  302.     { "" }
  303.     { author format.names.reverse1 }
  304.   if$
  305. }
  306.  
  307. FUNCTION {format.eds}
  308. { editor missing$
  309.     { "" }
  310.     { editor num.names$ #1 >
  311.     { editor format.names.reverse1 " (eds.)" * }
  312.     { editor format.names.reverse1 " (ed.)" * }
  313.       if$
  314.     }
  315.   if$
  316. }
  317.  
  318. FUNCTION {format.editors}
  319. { editor missing$
  320.     { "" }
  321.     { editor num.names$ #1 >
  322.     { editor format.names ", editors" * }
  323.     { editor format.names ", editor" * }
  324.       if$
  325.     }
  326.   if$
  327. }
  328.  
  329. FUNCTION {format.edited.by}
  330. { editor missing$
  331.     'skip$
  332.     { add.comma "edited by " * editor format.names * }
  333.   if$
  334. }
  335.  
  336. FUNCTION {format.title}
  337.  
  338. { title missing$
  339.     { "" }
  340.     { title "ul" change.case$ }
  341.   if$
  342.  
  343. }
  344.  
  345. FUNCTION {entry.string.max} { #100 }
  346.  
  347. FUNCTION {global.string.max} { #300 }
  348.  
  349. STRINGS {pageresult}
  350.  
  351. FUNCTION {n.dashify}
  352. { 't swap$ :=
  353.   'pageresult "" :=
  354.     { t "" = not }
  355.     { t #1 #1 substring$ "-" =
  356.     { t #1 #2 substring$ "--" = not
  357.         { 'pageresult pageresult "--" * :=
  358.           't t #2 global.string.max substring$ :=
  359.         }
  360.         {   { t #1 #1 substring$ "-" = }
  361.         { 'pageresult pageresult "-" * :=
  362.           't t #2 global.string.max substring$ :=
  363.         }
  364.           while$
  365.         }
  366.       if$
  367.     }
  368.     { 'pageresult pageresult t #1 #1 substring$ * :=
  369.       't t #2 global.string.max substring$ :=
  370.     }
  371.       if$
  372.     }
  373.   while$
  374.   pageresult
  375. }
  376.  
  377. FUNCTION {format.date}
  378. { year missing$
  379.     { month missing$
  380.     { "" }
  381.     { "Warning: there's a month but no year in " cite$ * top$
  382.       month
  383.     }
  384.       if$
  385.     }
  386.     { month missing$
  387.     { year }
  388.     { month " " * year * }
  389.       if$
  390.       extra.label *
  391.     }
  392.   if$
  393. }
  394.  
  395. FUNCTION {format.btitle}
  396. { title field.or.null
  397.   italicize
  398. }
  399.  
  400. FUNCTION {format.bvolume}
  401. { volume missing$
  402.     { series missing$
  403.     { "" }
  404.     { series italicize }
  405.       if$
  406.     }
  407.     { "vol.~" volume *
  408.       series missing$
  409.     'skip$
  410.     { " of " * series italicize * }
  411.       if$
  412.     }
  413.   if$
  414. }
  415.  
  416. FUNCTION {format.edition}
  417. { edition missing$
  418.     { "" }
  419.     { edition "ll" change.case$ " edition" * }
  420.   if$
  421. }
  422.  
  423. INTEGERS {multiresult}
  424.  
  425. FUNCTION {multi.page.check}
  426. { 't swap$ :=
  427.   'multiresult #0 :=
  428.     { multiresult not
  429.       t "" = not
  430.       and
  431.     }
  432.     { t #1 #1 substring$ "-" =
  433.       t #1 #1 substring$ "," =
  434.       or
  435.     { 'multiresult #1 := }
  436.     { 't t #2 global.string.max substring$ := }
  437.       if$
  438.     }
  439.   while$
  440.   multiresult
  441. }
  442.  
  443. FUNCTION {format.pages}
  444. { pages missing$
  445.     { "" }
  446.     { pages multi.page.check
  447.     { "pp.~" pages n.dashify * }
  448.     { "p.~" pages n.dashify * }
  449.       if$
  450.     }
  451.   if$
  452. }
  453.  
  454. FUNCTION {format.vol.num.pages}
  455. { volume field.or.null
  456.   number missing$
  457.     'skip$
  458.     { "(" number * ")" * *
  459.       volume missing$
  460.     { "Warning: there's a number but no volume in " cite$ * top$ }
  461.     'skip$
  462.       if$
  463.     }
  464.   if$
  465.   pages missing$
  466.     'skip$
  467.     { duplicate$ "" =
  468.     'skip$
  469.     { ":" * }
  470.       if$
  471.       pages n.dashify *
  472.     }
  473.   if$
  474. }
  475.  
  476. FUNCTION {format.vol.pages}
  477. { volume missing$
  478.     'skip$
  479.     {volume italicize}
  480.   if$
  481.   pages missing$
  482.     'skip$
  483.     { duplicate$ "" =
  484.     'skip$
  485.     { add.comma }
  486.       if$
  487.       pages n.dashify *
  488.     }
  489.   if$
  490. }
  491.  
  492. FUNCTION {format.chapter.pages}
  493. { chapter missing$
  494.     'format.pages
  495.     { "chapter~" chapter *
  496.       pages missing$
  497.     'skip$
  498.     { add.comma format.pages * }
  499.       if$
  500.     }
  501.   if$
  502. }
  503.  
  504. FUNCTION {format.in.ed.booktitle}
  505. { booktitle missing$
  506.     { "" }
  507.     { 's format.editors :=
  508.       s "" =
  509.     { "In " booktitle italicize * }
  510.     { "In " s * add.comma booktitle italicize * }
  511.       if$
  512.     }
  513.   if$
  514. }
  515.  
  516. FUNCTION {format.in.booktitle.ed}
  517. { booktitle missing$
  518.     { "" }
  519.     { "in " booktitle italicize *
  520.       format.edited.by
  521.     }
  522.   if$
  523. }
  524.  
  525. FUNCTION {format.tr.number}
  526. { type missing$
  527.     { "Technical Report" }
  528.     { type }
  529.   if$
  530.   number missing$
  531.     'skip$
  532.     { "~" * number * }
  533.   if$
  534. }
  535.  
  536. FUNCTION {article}
  537. { output.bibitem
  538.   "author" format.authors output.check
  539.   "title" format.title output.check
  540.   "journal" journal field.or.null italicize output.check
  541.   format.vol.pages output
  542.   "year" format.date output.check
  543.   note field.or.null output
  544.   fin.entry
  545. }
  546.  
  547. FUNCTION {book}
  548. { output.bibitem
  549.   author missing$
  550.     { "author and editor" format.eds output.check }
  551.     { "author" format.authors output.check }
  552.   if$
  553.   "title" format.btitle output.check
  554.   format.bvolume output
  555.   "publisher" publisher field.or.null output.check
  556.   address field.or.null output
  557.   format.edition output
  558.   "year" format.date output.check
  559.   note field.or.null output
  560.   fin.entry
  561. }
  562.  
  563. FUNCTION {booklet}
  564. { output.bibitem
  565.   format.authors output
  566.   "title" format.btitle output.check
  567.   howpublished field.or.null output
  568.   address field.or.null output
  569.   format.date output
  570.   note field.or.null output
  571.   fin.entry
  572. }
  573.  
  574. FUNCTION {inbook}
  575. { output.bibitem
  576.   author missing$
  577.     { "author and editor" format.eds output.check }
  578.     { "author" format.authors output.check }
  579.   if$
  580.   "title" format.btitle output.check
  581.   "chapter and pages" format.chapter.pages output.check
  582.   format.bvolume output
  583.   "publisher" publisher field.or.null output.check
  584.   address field.or.null output
  585.   format.edition output
  586.   "year" format.date output.check
  587.   note field.or.null output
  588.   fin.entry
  589. }
  590.  
  591. FUNCTION {incollection}
  592. { output.bibitem
  593.   "authors" format.authors output.check
  594.   "title" format.title output.check
  595.   "booktitle" format.in.booktitle.ed output.check
  596.   format.chapter.pages output
  597.   "publisher" publisher field.or.null output.check
  598.   address field.or.null output
  599.   "year" format.date output.check
  600.   note field.or.null output
  601.   fin.entry
  602. }
  603.  
  604. FUNCTION {inproceedings}
  605. { output.bibitem
  606.   "author" format.authors output.check
  607.   "title" format.title output.check
  608.   "booktitle" format.in.booktitle.ed output.check
  609.   format.pages output
  610.   organization field.or.null output
  611.   publisher field.or.null output
  612.   address field.or.null output
  613.   "year" format.date output.check
  614.   note field.or.null output
  615.   fin.entry
  616. }
  617.  
  618. FUNCTION {conference} { inproceedings }
  619.  
  620. FUNCTION {manual}
  621. { output.bibitem
  622.   format.authors output
  623.   "title" format.btitle output.check
  624.   organization field.or.null output
  625.   address field.or.null output
  626.   format.edition output
  627.   format.date output
  628.   note field.or.null output
  629.   fin.entry
  630. }
  631.  
  632. FUNCTION {mastersthesis}
  633. { output.bibitem
  634.   "author" format.authors output.check
  635.   "title" format.btitle output.check
  636.   "Master's thesis" output
  637.   "school" school field.or.null output.check
  638.   address field.or.null output
  639.   "year" format.date output.check
  640.   note field.or.null output
  641.   fin.entry
  642. }
  643.  
  644. FUNCTION {misc}
  645. { output.bibitem
  646.   format.authors output
  647.   format.title output
  648.   howpublished field.or.null output
  649.   format.date output
  650.   note field.or.null output
  651.   fin.entry
  652. }
  653.  
  654. FUNCTION {phdthesis}
  655. { output.bibitem
  656.   "author" format.authors output.check
  657.   "title" format.btitle output.check
  658.   "PhD thesis" output
  659.   "school" school field.or.null output.check
  660.   address field.or.null output
  661.   "year" format.date output.check
  662.   note field.or.null output
  663.   fin.entry
  664. }
  665.  
  666. FUNCTION {proceedings}
  667. { output.bibitem
  668.   editor missing$
  669.     { organization missing$
  670.     'skip$
  671.     { organization field.or.null output }
  672.       if$
  673.     }
  674.     { format.editors output }
  675.   if$
  676.   "title" format.btitle output.check
  677.   editor missing$
  678.     'skip$
  679.     { organization field.or.null output }
  680.   if$
  681.   publisher field.or.null output
  682.   address field.or.null output
  683.   "year" format.date output.check
  684.   note field.or.null output
  685.   fin.entry
  686. }
  687.  
  688. FUNCTION {techreport}
  689. { output.bibitem
  690.   "author" format.authors output.check
  691.   "title" format.btitle output.check
  692.   format.tr.number output
  693.   "institution" institution field.or.null output.check
  694.   address field.or.null output
  695.   "year" format.date output.check
  696.   note field.or.null output
  697.   fin.entry
  698. }
  699.  
  700. FUNCTION {unpublished}
  701. { output.bibitem
  702.   "author" format.authors output.check
  703.   "title" format.title output.check
  704.   format.date output
  705.   "note" note field.or.null output.check
  706.   fin.entry
  707. }
  708.  
  709. FUNCTION {default.type} { book }
  710.  
  711. MACRO {jan} {"January"}
  712.  
  713. MACRO {feb} {"February"}
  714.  
  715. MACRO {mar} {"March"}
  716.  
  717. MACRO {apr} {"April"}
  718.  
  719. MACRO {may} {"May"}
  720.  
  721. MACRO {jun} {"June"}
  722.  
  723. MACRO {jul} {"July"}
  724.  
  725. MACRO {aug} {"August"}
  726.  
  727. MACRO {sep} {"September"}
  728.  
  729. MACRO {oct} {"October"}
  730.  
  731. MACRO {nov} {"November"}
  732.  
  733. MACRO {dec} {"December"}
  734.  
  735. MACRO {bssa} {"Bull. Seis. Soc. Am."}
  736.  
  737. MACRO {grl} {"Geophys. Res. Lett."}
  738.  
  739. MACRO {jgr} {"J. Geophys. Res."}
  740.  
  741. MACRO {jgsa} {"J. Geol. Soc. Am."}
  742.  
  743. MACRO {mit} {"Mass. Inst. of Tech."}
  744.  
  745. MACRO {usgs} {"U.S. Geol. Surv."}
  746.  
  747. READ
  748.  
  749. FUNCTION {sortify}
  750. { purify$
  751.   "ll" change.case$
  752. }
  753.  
  754. FUNCTION {format.label.names}
  755. { 's swap$ :=
  756.   'numnames s num.names$ :=
  757.   numnames #1 >
  758.     { numnames #2 >
  759.     { 'namesleft #1 := }
  760.     { 'namesleft numnames := }
  761.       if$
  762.       'nameptr #1 :=
  763.       'nameresult "" :=
  764.     { namesleft #0 > }
  765.     { nameptr numnames =
  766.         { s nameptr "{ff}{vv}{ll}{jj}" format.name$ "others" =
  767.         { 'nameresult nameresult " et al." * := }
  768.         { nameresult "" =
  769.             'skip$
  770.             { 'nameresult nameresult " and " * := }
  771.           if$
  772.           'nameresult nameresult s nameptr "{vv}{ll}" format.name$
  773.           * :=
  774.         }
  775.           if$
  776.         }
  777.         { 'nameresult nameresult s nameptr "{vv}{ll}" format.name$
  778.           * :=
  779.         }
  780.       if$
  781.       'nameptr nameptr #1 + :=
  782.       'namesleft namesleft #1 - :=
  783.     }
  784.       while$
  785.       numnames #2 >
  786.     { 'nameresult nameresult " et al." * := }
  787.     'skip$
  788.       if$
  789.     }
  790.     { 'nameresult s #1 "{vv}{ll}" format.name$ :=
  791.     }
  792.   if$
  793.   nameresult
  794. }
  795.  
  796. FUNCTION {calc.label}
  797. { 'label
  798.   author missing$
  799.     { editor missing$
  800.     { key missing$
  801.         { "Warning: need a key to make a label in " cite$ * top$
  802.           title field.or.null purify$ #1 #3 substring$
  803.         }
  804.         { key purify$ #1 #3 substring$ }
  805.       if$
  806.     }
  807.     { editor format.label.names }
  808.       if$
  809.     }
  810.     { author format.label.names }
  811.   if$
  812.   add.comma
  813.   year field.or.null purify$
  814.   *
  815.   :=
  816.   'sort.label label sortify :=
  817. }
  818.  
  819. FUNCTION {sort.format.names}
  820. { 's swap$ :=
  821.   'nameptr #1 :=
  822.   'nameresult "" :=
  823.   'numnames s num.names$ :=
  824.   'namesleft numnames :=
  825.     { namesleft #0 > }
  826.     { nameptr #1 >
  827.     { 'nameresult nameresult "   " * := }
  828.     'skip$
  829.       if$
  830.  
  831.       't s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ :=
  832.  
  833.       nameptr numnames = t "others" = and
  834.     { 'nameresult nameresult "et al" * := }
  835.     { 'nameresult nameresult t sortify * := }
  836.       if$
  837.       'nameptr nameptr #1 + :=
  838.       'namesleft namesleft #1 - :=
  839.     }
  840.   while$
  841.   nameresult
  842. }
  843.  
  844. INTEGERS {len}
  845.  
  846. FUNCTION {chop.word}
  847. { 's swap$ :=
  848.   'len swap$ :=
  849.   s #1 len substring$ =
  850.     { s len #1 + global.string.max substring$ }
  851.     { s }
  852.   if$
  853. }
  854.  
  855. FUNCTION {sort.format.title}
  856. { 't swap$ :=
  857.   "A " #2
  858.     "An " #3
  859.       "The " #4 t chop.word
  860.     chop.word
  861.   chop.word
  862.   #1 global.string.max substring$
  863.   sortify
  864. }
  865.  
  866. FUNCTION {presort}
  867. {
  868.  
  869.   calc.label
  870.   sort.label
  871.   "    "
  872.   *
  873.  
  874.   author missing$
  875.     { editor missing$
  876.     { key field.or.null sortify }
  877.     { editor sort.format.names }
  878.       if$
  879.     }
  880.     { author sort.format.names }
  881.   if$
  882.  
  883.   *
  884.  
  885.   "    "
  886.   *
  887.   title field.or.null
  888.   sort.format.title
  889.   *
  890.   #1 entry.string.max substring$
  891.   'sort.key$ swap$ :=
  892. }
  893.  
  894. ITERATE {presort}
  895.  
  896. SORT
  897.  
  898. STRINGS { longest.label last.sort.label next.extra }
  899.  
  900. INTEGERS { longest.label.width last.extra.num }
  901.  
  902. FUNCTION {initialize.longest.label}
  903. { 'longest.label "" :=
  904.   'last.sort.label "" :=
  905.   'next.extra "" :=
  906.   'longest.label.width #0 :=
  907.   'last.extra.num #0 :=
  908. }
  909.  
  910. FUNCTION {forward.pass}
  911. { last.sort.label sort.label =
  912.     { 'last.extra.num last.extra.num #1 + :=
  913.       'extra.label last.extra.num int.to.chr$ :=
  914.     }
  915.     { 'last.extra.num "a" chr.to.int$ :=
  916.       'extra.label "" :=
  917.       'last.sort.label sort.label :=
  918.     }
  919.   if$
  920. }
  921.  
  922. FUNCTION {reverse.pass}
  923. { next.extra "b" =
  924.     { 'extra.label "a" := }
  925.     'skip$
  926.   if$
  927.   'label label extra.label * :=
  928.   label width$ longest.label.width >
  929.     { 'longest.label label :=
  930.       'longest.label.width label width$ :=
  931.     }
  932.     'skip$
  933.   if$
  934.   'next.extra extra.label :=
  935. }
  936.  
  937. EXECUTE {initialize.longest.label}
  938.  
  939. ITERATE {forward.pass}
  940.  
  941. REVERSE {reverse.pass}
  942.  
  943. FUNCTION {preamble}
  944. { "\begin{thebibliography}{X}" write$
  945.   newline$
  946. }
  947.  
  948. EXECUTE {preamble}
  949.  
  950. EXECUTE {init.state.consts}
  951.  
  952. ITERATE {call.type$}
  953.  
  954. FUNCTION {finish.up} { newline$ "\end{thebibliography}" write$ newline$ }
  955.  
  956. EXECUTE {finish.up}
  957.